//
//  NoticeCenterViewController.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/3/8.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "NoticeCenterViewController.h"

@interface NoticeCenterViewController ()
@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroView;
@property (strong, nonatomic) IBOutlet UILabel *noticeOneNumber;
@property (strong, nonatomic) IBOutlet UILabel *noticeTwoNumber;
@property (strong, nonatomic) IBOutlet UILabel *noticeThreeNumber;

@end

@implementation NoticeCenterViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self getNoticeNumber];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViewLayout];
    // Do any additional setup after loading the view.
}

- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.scroView];
    [self adaptiveViewLayout:self.navView];
    
    _scroView.contentSize = flexibleSize(CGSizeMake(0, 504.5), NO);
    
    _noticeOneNumber.layer.masksToBounds = YES;
    _noticeOneNumber.layer.cornerRadius = 6*VerticalRatio();
    
    _noticeTwoNumber.layer.masksToBounds = YES;
    _noticeTwoNumber.layer.cornerRadius = 6*VerticalRatio();
    
    _noticeThreeNumber.layer.masksToBounds = YES;
    _noticeThreeNumber.layer.cornerRadius = 6*VerticalRatio();
}

- (IBAction)back:(id)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}

#pragma mark === 获取消息条数
- (void)getNoticeNumber{

    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:SX_queryNotificationMessage withHttpType:@"POST" withTag:SX_SX_queryNotificationMessage];
}

#pragma mark == 通知信息
- (IBAction)noticeOneHandel:(id)sender {
    UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"PersonCenterStoryboard" bundle:nil];
    UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"NoticeMessage"];
    [self.navigationController   pushViewController:page animated:YES];
}
#pragma mark == 物业信息
- (IBAction)noticeTwoHandel:(id)sender {
    UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"PersonCenterStoryboard" bundle:nil];
    UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"Tenement"];
    [self.navigationController   pushViewController:page animated:YES];
}
#pragma mark == 优惠促销
- (IBAction)noticeThreehandel:(id)sender {
    UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"PersonCenterStoryboard" bundle:nil];
    UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"ForSale"];
    [self.navigationController   pushViewController:page animated:YES];
}


#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    if (tag == SX_SX_queryNotificationMessage){
        if (  [[database valueForKey:@"type"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            
        }else  {
            NSDictionary * dic = database[@"result"][0];
            _noticeOneNumber.text  =[NSString stringWithFormat:@"%@",dic[@"typeOne"]];
            _noticeTwoNumber.text  = [NSString stringWithFormat:@"%@",dic[@"typeTwo"]];
            _noticeThreeNumber.text  = [NSString stringWithFormat:@"%@",dic[@"typeThree"]];
            if([_noticeOneNumber.text isEqualToString:@"0"]){
                _noticeOneNumber.hidden = YES;
            }else{
                _noticeOneNumber.hidden = NO;
            }
            if([_noticeTwoNumber.text isEqualToString:@"0"]){
                _noticeTwoNumber.hidden = YES;
            }else{
                _noticeTwoNumber.hidden = NO;
            }
            if([_noticeThreeNumber.text isEqualToString:@"0"]){
                _noticeThreeNumber.hidden = YES;
            }else{
                _noticeThreeNumber.hidden = NO;
            }
        }
    }
}
-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
        
        //
        [self dismissWaitDialog];
        
        
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
